<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: show.phtml 5116 2010-08-30 03:16:31Z huuphuoc $
 * @since 		2.0.3
 */
?>
<?php if ($this->sizes) : ?>
<div class="t_utility_textresizer">
	<?php echo $this->translator()->widget('title'); ?>

	<span><a class="smaller" href="javascript: void(0);">A<sup>-</sup></a></span>
	<span><a class="default" href="javascript: void(0);">A</a></span>
	<span><a class="larger" href="javascript: void(0);">A<sup>+</sup></a></span>
</div>

<?php $this->headScript()->captureStart(); ?>
var sizes       = [ <?php echo $this->sizes; ?> ];
var defaultSize = parseInt('<?php echo $this->defaultSize; ?>');
var currentSize = defaultSize;

$(document).ready(function() {
	$('.t_utility_textresizer .smaller').click(function() {
		currentSize = (currentSize > sizes[0]) ? (currentSize - 1) : currentSize;
		Utility.Widgets.TextResizer.setSize(currentSize);
	});
	$('.t_utility_textresizer .default').click(function() {
		currentSize = defaultSize;
		Utility.Widgets.TextResizer.setSize(currentSize);
	});	
	$('.t_utility_textresizer .larger').click(function() {
		currentSize = (currentSize < sizes[sizes.length - 1]) ? (currentSize + 1) : currentSize;
		Utility.Widgets.TextResizer.setSize(currentSize);
	});	
});

'Utility.Widgets.TextResizer'.namespace();
Utility.Widgets.TextResizer.setSize = function(size) {
	if (currentSize != undefined) {
		$('head').find('style[type="text/css"]:last').remove();
	}
	$('<style type="text/css">body { font-size: ' + size + 'px; }</style>').appendTo('head');
};
<?php $this->headScript()->captureEnd(); ?>
<?php endif; ?>
